package com.personnelsystem;

import java.util.Scanner;

public class PersonnelSystem {
    static DatabaseConnection databaseConnection = new DatabaseConnection();
    private static MySqlDatabaseUse mySqlDatabaseUse = MySqlFactory.getMySqlDatabaseUse();
    public static void main(String[] args) throws Exception {
        try {
            System.out.println("---------欢迎使用人事数据管理系统---------");
            System.out.println("1.添加一个员工");
            System.out.println("2.删除一个员工");
            System.out.println("3.修改员工信息");
            System.out.println("4.全体：升薪-降薪");
            System.out.println("5.显示所有员工信息");
            System.out.println("0.退出系统");
            System.out.print("请输入您要办理的业务：");
            Scanner scanner = new Scanner(System.in);
            int x = scanner.nextInt();
            switch (x){
                case 1:
                    mySqlDatabaseUse.insert(databaseConnection.getConnetion());
                    main(args);
                    break;
                case 2:
                    mySqlDatabaseUse.remove(databaseConnection.getConnetion());
                    main(args);
                    break;
                case 3:
                    mySqlDatabaseUse.update(databaseConnection.getConnetion());
                    main(args);
                    break;
                case 4:
                    mySqlDatabaseUse.updateAll(databaseConnection.getConnetion());
                    main(args);
                    break;
                case 5:
                    mySqlDatabaseUse.select(databaseConnection.getConnetion());
                    main(args);
                    break;
                case 0:
                    System.out.println("系统已关闭");
                    System.exit(0);
                    break;
                default:
                    System.out.println("请输入正确的内容");
                    main(args);
                    break;
            }
        }catch (Exception e){
            System.out.println("请输入正确的内容");
            main(args);
        }
    }
}
